home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / bltc13.zip / !Q&A.TXT < prev    next >
Text File  |  1993-04-22  |  8KB  |  159 lines

  1. Questions & Answers
  2. BULLET v1.03, 22-Apr-93 (BLTC13)
  3.  
  4. Q: What is BULLET?
  5.  
  6. A: BULLET is a library of program modules that together let the programmer
  7.    develop and create software that can manage huge amounts of data on
  8.    disk using the industry-standard DBF data file format. It also uses high-
  9.    speed b-tree index files to manage keyed data file access.
  10.  
  11.  
  12. Q: What compiler is BULLET for?
  13.  
  14. A: BULLET can be used by nearly all DOS compilers. It's written entirely in
  15.    assembly language. Because of this, it does not require any particular
  16.    programming language or compiler vendor. The 4 requirements are listed
  17.    in the !WHATIS.TXT file.
  18.  
  19.  
  20. Q: Why do I need BULLET when all I need to handle are small amounts of data?
  21.  
  22. A: BULLET can deal with a database as small as 1 record or as large as several
  23.    million. While your current needs may be small, your future needs are bound
  24.    to expand. BULLET can work with you now, and later, even if you switch
  25.    development platforms by moving to another compiler. And BULLET is fast,
  26.    it can deal with a database with millions of records as easily as it can
  27.    with just a few.
  28.  
  29.  
  30. Q: But b-tree stuff, isn't that hard?
  31.  
  32. A: Everything associated with maintaining the database, its data files and its
  33.    index files, is done behind-the-scenes by BULLET. You just specify how the
  34.    data record is to look by specifying the number of fields, their lengths and
  35.    types, and then specify how you want your index files to be based.
  36.  
  37.  
  38. Q: So how do I design my data record?
  39.  
  40. A: You probably have a pretty good idea, already. A good way to determine what
  41.    should go into a database is what you want to come out of it. For example,
  42.    if you're doing a mailing list program, you'll want to have at least the
  43.    name, perhaps broken into first name and last. Also you'll need the mailing
  44.    address--4 lines is usually enough, so you'll want 4 separate address line
  45.    fields. Then there's the State and ZIP, possibly even country. That's the
  46.    minimum. It would look something like this:
  47.  
  48.    FIRSTNAME field of 15 characters; LASTNAME field of 19 characters; ADDR1
  49.    field of 34 characters, ADDR2, ADDR3, ADDR4 as ADDR1; State field of 2
  50.    characters, and ZIP a field of 5 (or 9 if ZIP+4) characters. You could
  51.    specify the ZIP as a numeric field if you wanted.
  52.  
  53.    You'll notice that the longest field is 34 characters. Why? Because most
  54.    mailing labels are 3.5 inches, about 34 characters across. Since the first
  55.    name and last are usually put on the same line, their total should be 34.
  56.  
  57.    You'll probably want to add more fields like telephone number, last time
  58.    written to, oh, just about anything that you'd think would be important to
  59.    know. There you go, you've just designed your data record.
  60.  
  61.  
  62. Q: Then what?
  63.  
  64. A: Then decide how you need to access this data. You'll want to access it at
  65.    least by name, so one index you'll want is on the name. While you could
  66.    specify the entire name be used as a key, say LASTNAME+FIRSTNAME, this is
  67.    a bit of overkill. Instead, you may want to use just a portion of the name.
  68.    A good candidate would be SUBSTR(LASTNAME,1,5)+SUBSTR(FIRSTNAME,1,1). This
  69.    sets up a key that's only 6 bytes long. The first method, using all the
  70.    name, would be 34 bytes long. By keeping your keys short you'll keep your
  71.    index files small and your index performance high. And yes, you can also
  72.    mix numeric field types with character field types in your key expressions.
  73.  
  74.  
  75. Q: But what if I have two or more names that are identical, or very similar
  76.    but have these parts of the names the same?
  77.  
  78. A: BULLET lets you specify if your index files allow only unique key entries or
  79.    whether duplicate keys are permitted. When keying on a name you should have
  80.    your index file allow duplicate keys. What BULLET does is number these
  81.    identical keys by adding a suffix to each key (called an enumerator). This
  82.    enumerator allows the index algorithm to treat each key as a different key.
  83.    If you search the index for all matches in the first 6 characters of the
  84.    key (the enumerators will always be different) these similar names will
  85.    be found in consecutive order. To find out if the key you've just accessed
  86.    is the actual person you had in mind, you'd scan the data record associated
  87.    with that key for other information, such as middle initial, address,
  88.    anything that would make that person recognizable from another with a
  89.    similar key. If it isn't what you're looking for, get the next key and data
  90.    record, and so on until the first 6 characters of the key no longer are the
  91.    6 you're looking for.
  92.  
  93.  
  94. Q: So I've got my data record designed and also my primary index file. What
  95.    else should I do?
  96.  
  97. A: Now that the database is designed most of the "unknown" is taken care of.
  98.    What comes next depends on how you, yourself, program. What I often do
  99.    next is detail exactly what I want the output to be. That way, I've got
  100.    the front and the back and just need to do the middle. The middle is where
  101.    the fun's at. You'll be amazed at just how few of your in-the-middle coding
  102.    is spent on managing the database. BULLET takes care of all the little
  103.    details. You just need to give it the data and tell it what to do with
  104.    it. Or you tell it what to get and it comes back with what you requested.
  105.    You then do whatever you want with that data.
  106.  
  107.  
  108. Q: I've looked at the header file and it sure has a lot of commands. You're
  109.    telling me that this is simple?
  110.  
  111. A: Yes. Once you've created your data and index files, those mid-level
  112.    routines are not often used. Almost everything you do in your in-the-middle
  113.    coding will use the high-level routines. The InsertXB and UpdateXB routines
  114.    handle adding new or changing existing data, and the GetFirstXB, GetNextXB,
  115.    etc., routines handle getting the data. 90% of the time these are the
  116.    routines your program will be using.
  117.  
  118.  
  119. Q: What about all those packs? How can I keep them straight?
  120.  
  121. A: The good thing about modern programming langauges is that they let you
  122.    build reusable code. The ideal way to use BULLET is to build reusable
  123.    code objects in your programming langauge of choice and hide the down-and-
  124.    dirty aspects of dealing with the various packs in those objects. For
  125.    example, a create key routine could be written once and that object used
  126.    for all your other programming projects.
  127.  
  128.  
  129. Q: I think I'm getting the hang of it. What's next?
  130.  
  131. A: Jump in and start coding. You may want to look over, maybe even print out,
  132.    one of the example programs. The BC_LAI10.BAS is straight forward, try
  133.    that. If you have any questions, just pop-up CZ. It's all in there.
  134.  
  135.  
  136. Q: Sounds good. But, tell me, what is the first thing I'm likely to muff?
  137.  
  138. A: Nothing serious. Just make sure that your record structure in memory
  139.    reserves the first byte for the delete tag. Also, make sure that the field
  140.    descriptors you assigned when you created the data file match your in-memory
  141.    structure, i.e., if you've created a data file (using CreateDXB) with say, 3
  142.    fields, each 25 characters long, make sure that your in-memory structure is
  143.    also 3 fields, each 25 characters.
  144.  
  145.    Note: it is allowable to alias your physical fields but the total length
  146.    must match the total length of the DBF data record. (Alias meaning that
  147.    instead of using Field1[25], you use Field1a[13] and Field1b[12]. Be sure
  148.    you know what you're doing!
  149.  
  150.    Also, the transaction routines (InsertXB, UpdateXB, ReindexXB, and the
  151.    LockXBs) return a transaction index rather than a completion code. Be sure
  152.    to check the documentation for the routines.
  153.  
  154. Q: I'm off.
  155.  
  156. A: So am I, but be sure to...
  157.  
  158.    ...Read the manual! Until you do you can't take full advantage of BULLET.
  159.